package cn.lanqiao.web.controller;

import cn.lanqiao.common.entity.Cinema;
import cn.lanqiao.common.utile.Result;
import cn.lanqiao.common.vo.CinemaVo;
import cn.lanqiao.system.service.CinemaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/cinema")
@CrossOrigin
public class CinemaController {
    @Autowired
    public CinemaService cinemaService;
    //电影院查询
    @RequestMapping("/getAllCinema")
    public Result getAllCinema(){
        try {
            List<Cinema> cinemaList = cinemaService.getAllCinema();
            return Result.ok(cinemaList);
        }catch (Exception e){
            e.printStackTrace();
        }
        return Result.fail("系统错误");
    }

    //电影院模糊查询
    @RequestMapping("/findCinemaName")
    public Result findCinemaName(String value){
        try {
            List<Cinema> cinemaList = cinemaService.findCinemaName(value);
            return Result.ok(cinemaList);
        }catch (Exception e){
            e.printStackTrace();
        }
        return Result.fail("系统错误");
    }
    //查询电影院所有的电影和所有放映厅
    @RequestMapping("/findAll")
    public Result findAll(Integer id){
        System.out.println("----"+id);
        try {
            List<CinemaVo> list=cinemaService.findAll(id);
            return Result.ok(list);
        }catch (Exception e){
            e.printStackTrace();
        }
        return Result.fail("系统出错！");
    }
}
